package com.car.web.controller.interfaceController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.car.dal.dao.goods.TgGoodsAccountDao;
import com.car.dal.dao.goods.TgGoodsDao;
import com.car.dal.dao.goods.TgGoodsKeyDao;
import com.car.dal.dao.grade.TgUsergradeDao;
import com.car.dal.dao.moneys.TgMoneyDao;
import com.car.dal.dao.office.TgOfficeDao;
import com.car.dal.dao.period.TgPeriodDao;
import com.car.dal.dao.reception.TgReceptionDao;
import com.car.dal.dao.source.TgSourceDao;
import com.car.dal.dao.sudent.StudentDao;
import com.car.dal.dao.teastu.TeacherStuDao;
import com.car.dal.dao.user.UserDao;
import com.car.dal.dao.user.UserinfoDao;
import com.car.dal.object.TgUserinfo;
import com.car.service.reception.ReceptionService;
import com.car.service.tgPeriod.TgPeriodService;
import com.car.util.JsonExecutor;
import com.car.util.Result;
import com.car.util.ResultSupport;
import com.car.util.WebExecutor;
import com.car.util.JsonExecutor.JsonBiz;
import com.car.util.WebExecutor.Biz;
import com.car.web.controller.base.BaseController;
import com.car.web.controller.base.BaseVo;


@Controller
@RequestMapping("/oa")
public class TeacherController extends BaseController{
	private static final Logger logger = Logger.getLogger(TeacherController.class);
	private static SimpleDateFormat sdf=new  SimpleDateFormat("yyyy-MM-dd");
	
	@Resource
	private StudentDao studentDao;
	@Resource
	private UserinfoDao userinfoDao;
	@Resource
	private TgReceptionDao receptionDao;
	@Resource
	private TgMoneyDao moneyDao;
	@Resource
	private TgOfficeDao tgOfficeDao;
	@Resource
	private TgGoodsDao goodsDao;
	@Resource
	private TgGoodsAccountDao tgGoodsAccountDao;
	@Resource
	private TgGoodsKeyDao tgGoodKeyDao;
	@Resource
    private TgUsergradeDao usergradeDao;
	@Resource
    private UserDao userDao;
	@Resource
    private ReceptionService receptionService;
	@Resource
	private TgPeriodService tgPeriodService;
	@Resource
	private TgPeriodDao  tgPeriodDao;
	@Resource
	private TeacherStuDao teaStuDao;
	@Resource
    private TgSourceDao sourceDao;
	
	@RequestMapping(value = "/teacherlist")
    public ModelAndView teacherlist(ModelMap modelMap, final BaseVo vo,
       final HttpServletRequest request, final HttpServletResponse response)
            throws Exception {
        modelMap = WebExecutor.execute(logger, vo, new Biz() {
            public Result process() {
                Result result = new ResultSupport(true);
                
                TgUserinfo user = new TgUserinfo();
                user.setJob("课程顾问");
                List<TgUserinfo> uList1 = userinfoDao.getUserInfoByUserInfo(user);

                TgUserinfo user1 = new TgUserinfo();
                user1.setJob("在线课程顾问");
                List<TgUserinfo> uList = userinfoDao.getUserInfoByUserInfo(user1);

                result.setDefaultModel("uList1", uList1);
                result.setDefaultModel("uList", uList);
                return result;
            }
        });
        return new ModelAndView("", modelMap);
    }

	@RequestMapping(value = "/teacherlist2")
	public ModelAndView teacherlist2(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, final HttpServletResponse response)
					throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				TgUserinfo user = new TgUserinfo();
				user.setId(Integer.parseInt(id));
				List<TgUserinfo> uList1 = userinfoDao.getUserInfoByUserInfo2(user);
		
				result.setDefaultModel("uList1", uList1);
				
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	@RequestMapping(value = "/centerteacherlist")
    public ModelAndView centerteacherlist(ModelMap modelMap, final BaseVo vo,
       final HttpServletRequest request, final HttpServletResponse response)
            throws Exception {
        modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
            public Result process() {
                Result result = new ResultSupport(true);
                TgUserinfo user = new TgUserinfo();
                user.setJob("课程顾问");
                List<TgUserinfo> uList1 = userinfoDao.getUserInfoByUserInfo(user);

                TgUserinfo user1 = new TgUserinfo();
                user1.setJob("在线课程顾问");
                List<TgUserinfo> uList = userinfoDao.getUserInfoByUserInfo(user1);

                result.setDefaultModel("uList1", uList1);
                result.setDefaultModel("uList", uList);
                return result;
            }
        });
        return new ModelAndView("", modelMap);
    }
	//通过老师ID查询信息
	@RequestMapping(value = "/teacherlist3")
	public ModelAndView teacherlist3(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, final HttpServletResponse response)
					throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				TgUserinfo user = new TgUserinfo();
				user.setId(Integer.parseInt(id));
				List<TgUserinfo> uList1 = userinfoDao.getUserInfoByUserInfo4(user);
		
				result.setDefaultModel("uList1", uList1);
				
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
}
